<?php

class menuBuilder{

//Properties
	private $menuType;
	private $menuList;
	
	public function __construct($menuType)
	{
		$this->menuType = $menuType;
	}
	
	public function printMenu()
	{
	$toEcho = "";
		if($this->menuType == "voyage")
		{
			$toEcho .= "<ul class='second'>";
			 $this->loadVoyageList();
			 foreach($this->menuList as $value)
			 {
				$toEcho .= '<li><a href="photos.php?voyage='.$value.'">'.ucwords(strtolower($value)).'</a></li>';
			 }
			 $toEcho .= "</ul>";
		}
		echo $toEcho;
	}
	
	private function loadVoyageList()
	{
		if($directoryHandler = opendir("images/"))
		{
			while(($folder = readdir($directoryHandler)) !== false)
			{
				if ($folder != "." && $folder != ".." && is_dir("images/".$folder)) {
					$this->menuList[] = $folder;
				}
			}
		}
		else
		{
				//Exception, impossible to open the folder
		}
	}
}
